package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

func main() {
	router := gin.Default()
	router.LoadHTMLGlob("templates/**/*")
	// router.LoadHTMLFiles("templates/posts/index.html", "templates/users/index.html")
	router.GET("posts/index", func(c *gin.Context) {
		c.HTML(http.StatusOK, "posts/index.html", gin.H{
			"title": "posts/index",
		})
	})

	router.GET("users/index", func(c *gin.Context) {
		c.HTML(http.StatusOK, "users/index.html", gin.H{
			"title": "users/index",
		})
	})

	// 路由组
	someGroup := router.Group("/someGroup")
	someGroup.GET("/someGet", func(c *gin.Context) {
		c.HTML(http.StatusOK, "posts/index.html", gin.H{
			"title": "someGroup/someGet",
		})
	})
	someGroup.POST("/somePost", func(c *gin.Context) {
		c.HTML(http.StatusOK, "posts/index.html", gin.H{
			"title": "someGroup/somePost",
		})
	})

	router.Run(":9090")
}
